﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MVVMEx1.Model
{
    public class NhanVienServices : INhanVienServices
    {
        public async Task<System.Collections.ObjectModel.ObservableCollection<NhanVien>> DSNhanVien()
        {
            ObservableCollection<NhanVien> obColNV = new ObservableCollection<NhanVien>();
            try
            {
                var dbpath = Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, @"Data\QuanLyNhanSu.db");
                var db = new SQLite.SQLiteAsyncConnection(dbpath);
                var nvien = await db.QueryAsync<NhanVien>("SELECT * FROM NhanVien");

                foreach (var item in nvien)
                {
                    obColNV.Add(item);
                }
            }
            catch (System.Exception ex)
            {

            }
            return obColNV;
        }
    }
}
